package de.tempel.pong.objects.basic;

import java.awt.geom.Point2D;

/**
 * 
 * Bewegungsvektor für Spielobjekte.
 * 
 * @author mathias
 * 
 */
public class Vector {

	private double x;
	private double y;

	/**
	 * 
	 * @param x
	 * @param y
	 */
	public Vector(double x, double y) {
		this.x = x;
		this.y = y;
	}

	/**
	 * 
	 * @param v
	 */
	public Vector(Vector v) {
		this(v.getX(), v.getY());
	}

	/**
	 * Multipliziert Vektor mit Faktor.
	 * 
	 * @param fac
	 */
	public void multiply(double fac) {
		this.x = this.x * fac;
		this.y = this.y * fac;
	}

	/**
	 * 
	 * @param point
	 * @return verschobener Punkt
	 */
	public Point2D movePoint(Point2D point) {
		double newX = point.getX() + x;
		double newY = point.getY() + y;
		return new Point2D.Double(newX, newY);
	}

	/**
	 * 
	 * @return Länge des Vektors
	 */
	public double length() {
		return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2));
	}

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

}
